include('shared.lua')

function MsgMoneyVault(msg)
	local Amount = msg:ReadString()
	local vault = msg:ReadShort()

	local DFrame1 = vgui.Create('DFrame')
	DFrame1:SetSize(176, 92)
	DFrame1:Center()
	DFrame1:SetTitle('Money Vault')
	DFrame1:SetSizable(false)
	DFrame1:SetDeleteOnClose(false)
	DFrame1:MakePopup()
	
	if(Amount ~= "0") then	
		local DButton1 = vgui.Create('DButton')
		DButton1:SetParent(DFrame1)
		DButton1:SetSize(78, 20)
		DButton1:SetPos(49, 66)
		DButton1:SetText('Eject Money')
		DButton1.DoClick = function() LocalPlayer():ConCommand("withdrawmoney " .. vault .. "\n") DFrame1:Remove() end 

		local DLabel2 = vgui.Create('DLabel')
		DLabel2:SetParent(DFrame1)
		DLabel2:SetPos(75, 49)
		DLabel2:SetText('$'..Amount)
		DLabel2:SizeToContents()

		local DLabel1 = vgui.Create('DLabel')
		DLabel1:SetParent(DFrame1)
		DLabel1:SetPos(12, 32)
		DLabel1:SetText('Amount stored in Money Vault:')
		DLabel1:SizeToContents()
	else 	
		local DLabel1 = vgui.Create('DLabel')
		DLabel1:SetParent(DFrame1)
		DLabel1:SetPos(25, 45)
		DLabel1:SetText('This Money Vault is empty.')
		DLabel1:SizeToContents()
	end
end
usermessage.Hook("moneyvaultgui", MsgMoneyVault)